#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>


/*int
my_isword(const char* str, const char* word)
{
	int i = 0;
	while (*(word+i) != '\0' && *(str+i) != '\0') {
		if (*(word+i) != *(str+i)) {
			return 0;
		}
		++i;
	}
	if (*(str+i) != '\0' && ( ispunct(*(str+i)) || isspace(*(str+i)) ) )
		return 1;
	return 0;
} */


int
main(int argc, char** argv)
{
	int n,m,i=0,result=0;
	char stroka[256], slova[10][21];
	char *word;
	freopen("misslksh.in", "rt", stdin);
	freopen("misslksh.out", "w", stdout);

	scanf("%d", &n);
	while (i<n)
		(void) scanf("%s", slova[i++]);

	scanf("%d\n", &m);
	while (m-- >= 0) {
		word = fgets(stroka, 256, stdin);
		if (word != NULL && *word != '\n') { /* avoid NULL deref-ing */
			word = strtok(word, " ,.!?\n");
			if (word != NULL) /* NULL deref */
				*(word + (int)strcspn(word, " ,.!?\n")) = 0;
			while (word != NULL && *word != '\0') {
				for (i = 0; i < n; ++i)
					if (!strcmp(word, slova[i])) {
						++result;
						(void) fprintf(stderr, " [%s]", word);
						break;
					}
				word = strtok(NULL, " ,.!?\n");
			}
		(void) fprintf(stderr, "\n");
		}
	}

	printf("%d\n", result);

	return 0;
}
